/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.view.orderView;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

import com.ruipengkj.ApplicationContext;
import com.ruipengkj.CardComponentListener;
import com.ruipengkj.bean.TBillDetail;
import com.ruipengkj.bean.TCommodity;
import com.ruipengkj.bean.TConfig;
import com.ruipengkj.bean.TOrder;
import com.ruipengkj.bean.TStock;
import com.ruipengkj.bean.TStockInOut;
import com.ruipengkj.bean.TStockInOutDetail;
import com.ruipengkj.bean.TStore;
import com.ruipengkj.bean.TUser;
import com.ruipengkj.commons.BuildSpringApplication;
import com.ruipengkj.commons.util.TopBottomLineBorder;
import com.ruipengkj.commons.util.UUID;
import com.ruipengkj.commons.util.Util;
import com.ruipengkj.commons.util.display.ClientDisplay;
import com.ruipengkj.commons.util.print.TicketPrint;
import com.ruipengkj.component.JLabelJTextFieldComponent;
import com.ruipengkj.component.RPJButtonBlue;
import com.ruipengkj.component.RPJButtonWhite;
import com.ruipengkj.component.comboBox.CommodityJComboBoxTableComponent;
import com.ruipengkj.component.jpanel.QueryPanel;
import com.ruipengkj.component.jpanel.RepeatImagePanel;
import com.ruipengkj.component.jtable.RPTable;
import com.ruipengkj.factory.ImageFactory;
import com.ruipengkj.model.MemberConsumptionCellEditorTextField;
import com.ruipengkj.model.MemberConsumptionModel;
import com.ruipengkj.service.TBillDetailService;
import com.ruipengkj.service.TConfigService;
import com.ruipengkj.service.TStockInOutDetailService;
import com.ruipengkj.service.TStockInOutService;
import com.ruipengkj.service.TStockService;
import com.ruipengkj.service.TUserService;
import com.ruipengkj.view.base.BasePanel;

/**
 * 说明： 会员卡消费UI
 * 
 * @Author：黄盛强
 * @Date：2012-03-20
 */
public class MemberConsumptionPanel extends BasePanel {

	private static final long serialVersionUID = 1L;

	// 查询右边显示
	private JLabelJTextFieldComponent trueNameTemp, moneyTemp, pointTemp,
			userLevelName;// cartIDTemp,mobileTemp;
	
	private JLabelJTextFieldComponent carIDTF = null; // 会员卡号
	private JButton checkMenberButton = null; // 查看会员信息
	private JLabelJTextFieldComponent telTF = null; // 手机号

	private JLabelJTextFieldComponent OrderNumTF = null;// 订单号

	private JTable table = null;// 订单Table
	private MemberConsumptionModel memberConsumptionModel;// model
	private JScrollPane tableJsp;
	private JLabelJTextFieldComponent totalMoneyTF = null;// 总金额
	private JLabelJTextFieldComponent receivableMoneyTF = null;// 应收金额
	private JLabelJTextFieldComponent discountTF = null;// 折扣
	private JLabelJTextFieldComponent privilegeTF = null;// 优惠
	private JLabelJTextFieldComponent menberLevelTF = null;// 会员级别
	
	private JButton sureButton = null; // 确定按钮
	private JButton cancelButton = null; // 取消
	private TUserService tUserService;// 会员
	private TBillDetailService tBillDetailService;// 单据商品明细
	private TStockService tStockService;// 商品库存
	private TStockInOutService tStockInOutService;// 出入库单
	private TStockInOutDetailService tStockInOutDetailService;// 出入库单详细
	private TConfigService tConfigService;// 系统设置
	private TUser tUser;
	private MemberConsumptionConfirmPaymentDailog dialog;// 结账窗体

	public MemberConsumptionPanel() {
		tStockInOutDetailService = BuildSpringApplication.getInstance()
				.getTStockInOutDetailServiceImpl();
		
		tStockInOutService = BuildSpringApplication.getInstance()
				.getTStockInOutServiceImpl();
		tStockService = BuildSpringApplication.getInstance()
				.getTStockServiceImpl();
		tUserService = BuildSpringApplication.getInstance()
				.getTUserServiceImpl();
		tBillDetailService = BuildSpringApplication.getInstance()
				.getTBillDetailServiceImpl();
		tConfigService = BuildSpringApplication.getInstance()
				.getTConfigServiceImpl();
		this.setLayout(new BorderLayout());
		this.init();
		this.initListener();
		
		ApplicationContext.listenCard(carIDTF.getText(), ApplicationContext.CardType.CT_DLSended);
		carIDTF.getText().addComponentListener(new CardComponentListener());
	}

	private JTable createJTable(AbstractTableModel model,MouseMotionListener mm, MouseListener ml, int rowHeight, int align) {
	
		JTable table = new RPTable(model) {
			private static final long serialVersionUID = 1L;
			@Override
			public void changeSelection(int rowIndex, int columnIndex,
					boolean toggle, boolean extend) {
				super.changeSelection(rowIndex, columnIndex, toggle, extend);
				super.editCellAt(rowIndex, columnIndex, null);
			}
		};
		table.addMouseMotionListener(mm);
		table.addMouseListener(ml);
		table.setRowHeight(rowHeight);
		table.getTableHeader().setReorderingAllowed(false);
		// 表格居中
		DefaultTableCellRenderer defaultTableCellRenderer = new DefaultTableCellRenderer();
		defaultTableCellRenderer.setHorizontalAlignment(align);
		table.setDefaultRenderer(Object.class, defaultTableCellRenderer);
		return table;
	}

	private void init() {
		memberConsumptionModel = new MemberConsumptionModel(this);
		table = createJTable(memberConsumptionModel, this, this, 30,JLabel.CENTER);
		TableColumnModel colmodel = table.getColumnModel();
		for (int index = 0; index < table.getColumnCount(); index++) {
			TableColumn tc = colmodel.getColumn(index);
			JTextField editor = new JTextField();
			MemberConsumptionCellEditorTextField cellEditor = new MemberConsumptionCellEditorTextField(
					editor);
			cellEditor.setClickCountToStart(1);
			tc.setCellEditor(cellEditor);
		}

		CommodityJComboBoxTableComponent cbox = new CommodityJComboBoxTableComponent();
		cbox.setBorder(null);
		TableCellEditor edt = new DefaultCellEditor(cbox);
		table.getColumnModel().getColumn(2).setCellEditor(edt);
		table.addKeyListener(this);
		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		tableJsp = uiFactory.createJScrollPane(table);
		tableJsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

		this.add(this.topPanel(), BorderLayout.NORTH);
		this.add(tableJsp, BorderLayout.CENTER);
		this.add(this.downMainPanel(), BorderLayout.SOUTH);
		this.setTableEdit(0, 1);
		
	}
//
	private JPanel downMainPanel() {
		JPanel jp = new RepeatImagePanel(ImageFactory.loadImage(ImageFactory.DOWN_BG_1).getImage());
		jp.setLayout(new FlowLayout(FlowLayout.RIGHT));
		JLabelJTextFieldComponent employeesTF = new JLabelJTextFieldComponent("操作员：", 10,20);
		employeesTF.getText().setText(ApplicationContext.OPERATOR_NAME);
		employeesTF.getText().setEditable(false);
		receivableMoneyTF = new JLabelJTextFieldComponent("应收金额：", 8,20);
		totalMoneyTF = new JLabelJTextFieldComponent("总金额：", 8,20);
		discountTF = new JLabelJTextFieldComponent("折扣：", 5,20);
		privilegeTF = new JLabelJTextFieldComponent("优惠：", 5,20);
		menberLevelTF = new JLabelJTextFieldComponent("会员级别：", 10,20);
		sureButton = new RPJButtonWhite("确定(CTRL+Y)");
		cancelButton = new RPJButtonWhite("清空");
		receivableMoneyTF.getText().setEditable(false);
		totalMoneyTF.getText().setEditable(false);
		discountTF.getText().setEditable(false);
		privilegeTF.getText().setEditable(false);
		menberLevelTF.getText().setEditable(false);
		receivableMoneyTF.getText().setText("0.00");
		totalMoneyTF.getText().setText("0.00");
		discountTF.getText().setText("无");
		privilegeTF.getText().setText("0.00");
		menberLevelTF.getText().setText("无");
		jp.add(employeesTF);
		jp.add(receivableMoneyTF);
		jp.add(totalMoneyTF);
		jp.add(discountTF);
		jp.add(privilegeTF);
		jp.add(menberLevelTF);
		jp.add(sureButton);
		jp.add(cancelButton);
		return jp;
	}

	// 头部面板
	private JPanel topPanel() {
		QueryPanel queryPanel=new QueryPanel("商店销售",ImageFactory.loadImage(ImageFactory.FUN_1_ICON_1));
		
		JPanel panel = uiFactory.createFlowJPanel(FlowLayout.LEFT);
		carIDTF = new JLabelJTextFieldComponent(" 会员卡号：", 20);
		ApplicationContext.tf = carIDTF.getText();
		telTF = new JLabelJTextFieldComponent(" 手 机 号：", 20);
		OrderNumTF = new JLabelJTextFieldComponent(" 订 单 号：", 20);
		OrderNumTF.getText().setText(UUID.GenUUID15());
		OrderNumTF.getText().setEditable(false);
		checkMenberButton = new RPJButtonBlue("查询");
		panel.add(carIDTF);
		panel.add(telTF);
		panel.add(OrderNumTF);
		panel.add(checkMenberButton);
//		panel.add(this.showMenberInfoPanel());
//		queryPanel.addPanel(panel);
//		queryPanel.addBoxPanel(panel);
		
		
//		JPanel jp=uiFactory.createBorderJPanel();
//		jp.add(queryPanel, BorderLayout.CENTER);
//		jp.add(showMenberInfoPanel(), BorderLayout.SOUTH);
		JPanel jp=new JPanel(new GridLayout(2, 1));
		jp.add(panel);
		jp.add(showMenberInfoPanel());
		queryPanel.addPanel(jp);
		
		return queryPanel;
	}


	private void initListener() {
		telTF.getText().addKeyListener(this);
		checkMenberButton.addActionListener(this);
		sureButton.addActionListener(this);
		cancelButton.addActionListener(this);
		sureButton.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
		cancelButton.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
	}

	@Override
	public void keyReleased(KeyEvent e) {
		if (e.getSource() == table) {
			if (e.getKeyCode() == KeyEvent.VK_DELETE) {
				if (Util.showConfirmDialog("是否要删除选中行？") == 0) {
					if (table.getRowCount() > 1) {
						memberConsumptionModel.deleteList(table.getSelectedRow());
					} else {
						memberConsumptionModel.updateList(table.getSelectedRow(), new TCommodity());
					}
				}
			} else if (e.getKeyCode() == KeyEvent.VK_F11) {
				this.setTableEdit(table.getRowCount() - 1, 1);
			} else if (e.getKeyCode() == KeyEvent.VK_F12) {
				if (table.getSelectedRow() >= 0&& table.getSelectedRow() < table.getRowCount() - 2) {
					setTableEdit(table.getSelectedRow(), 4);// 如果选中talbe中的商品，则聚焦在条码单元格上
				} else {
					if (table.getRowCount() > 1)// 如果没有选中table的商品，则聚焦在最后一件商品的条码单元格上
						setTableEdit(table.getRowCount() - 2, 4);
				}
			}
		} else if (e.getSource() == telTF.getText()) {
			// 查询会员
			if (e.getKeyCode() == KeyEvent.VK_ENTER) {
				lookMember();
				this.setOrderData();
			}
		} 
	}

	public void setTableEdit(int row, int column) {
		table.setRowSelectionInterval(row, row);
		table.setColumnSelectionInterval(column, column);
		table.setEditingColumn(column);
		table.setEditingRow(row);
	}

	@Override
	public void actionPerformed(ActionEvent e) {

		if (e.getSource() == checkMenberButton) {
			// 查看会员
			lookMember();
		} else if (e.getSource() == cancelButton) {
			// 清空
			if (Util.showConfirmDialog("是否要清空当前数据？") == 0) {
				this.clear();
			}
		} else if (e.getSource() == sureButton) {
			// 确定
			if (memberConsumptionModel.getTCommodityList().size() < 2) {
				JOptionPane.showMessageDialog(null, "购买商品为空");
				return;
			}
			TConfig tConfig = null; // 判断是否有设置销售仓库
			try {
				List<TConfig> tConfigList = tConfigService.findService(null);
				if (tConfigList == null || tConfigList.size() == 0
						|| tConfigList.get(0).getSellStoreID() == null
						|| tConfigList.get(0).getSellStoreID().equals("")) {
					Util.showMessageDialog("请先设置销售仓库");
					return;
				} else {
					tConfig = tConfigList.get(0);
					List<TCommodity> list = memberConsumptionModel.getTCommodityList();
					for (int i = 0; i < list.size(); i++) {// 判断在销售仓库中是否存在此商品
						TCommodity tCommodity = list.get(i);
						if (tCommodity.getBarcode() != null&& !tCommodity.getBarcode().equals("")) {
							TStock tStock = new TStock();// 根据商品、仓库查出库存
							tStock.setTStore(new TStore(tConfig.getSellStoreID()));
							tStock.setTCommodity(tCommodity);
							List<TStock> tStockList = tStockService.findService(tStock);
							if (tStockList == null || tStockList.size() == 0) {
								Util.showMessageDialog("第" + (i + 1)+ "件商品，在销售仓库中不存在");
								return;
							}
						}
						
						//比较库存量，是否足够销售
						int num = ApplicationContext.stockTotalNum(tCommodity.getCommodityID(), null);
						if (tCommodity.getNum() > num) {
							Util.showMessageDialog("第" + (i + 1)+ "件商品，总库存量：" + num + " 无法销售！");
							return;
						}
					}
				}
			} catch (Exception e2) {
				e2.printStackTrace();
			}

			String number = carIDTF.getText().getText().trim();
			if (number.length() > 15) {
				JOptionPane.showMessageDialog(null, "会员卡号不能超过15个字");
				return;
			}
			dialog = new MemberConsumptionConfirmPaymentDailog(null, "支付", true);
			dialog.showDialog(tUser, memberConsumptionModel.getTotalManay(), new TOrder(OrderNumTF.getText().getText().trim()), null);
			if (dialog.isSuccess) {
				try {
					List<TCommodity> list = memberConsumptionModel
							.getTCommodityList();
					List<TBillDetail> detailList = new ArrayList<TBillDetail>();
					for (int i = 0; i < list.size(); i++) {
						TCommodity tCommodity = list.get(i);
						if (tCommodity.getBarcode() != null&& !tCommodity.getBarcode().equals("")) {
							TStock tStock = new TStock();// 根据商品、仓库查出库存
							tStock.setTStore(new TStore(tConfig.getSellStoreID()));
							tStock.setTCommodity(tCommodity);
							tStock = tStockService.findService(tStock).get(0);
							int num = tCommodity.getNum();// 此商品销售的数量
							tStock.setNum(tStock.getNum() - num);
							tStockService.saveOrUpdateService(tStock);
							
							TStockInOutDetail tStockInOutDetial = new TStockInOutDetail();// 添加出入库单明细

							TStockInOut tStockInOut = new TStockInOut();// 添加出入单号
							tStockInOut.setInOutID(UUID.GenUUID15());// 入/出库单编号CHAR(15)PK
							tStockInOut.setType(ApplicationContext.STOCK_TYPE_OUT);// 入/出类型TINYINT
							// 1为入库单
							// 2为出库单
							tStockInOut.setSourceType(ApplicationContext.STOCK_IN_OUT_SOURCE_TYPE3);// 1为采购所引起的入库，原因单为采购单编号
							// 2为采购退货所引起的出库，原因单为退货单
							// 3为销售定单所引起的出库，原因单为销售定单 4为销售退货所引起的入库，原因单为销售退货单
							// 5为员工领用所引起的出库，原因单为领用单 6为报损所引起的出库，原因单为报损单
							// 7为仓库调度所引起的出库，原因单为仓库调拨单 8为仓库调度所引起的入库，原因单为仓库调拨单
							// 9为生产材料领用出库 10为生产成品入库 100为未知原因的入库 101为未知原因的出库
							tStockInOut.setSource(OrderNumTF.getText().getText());// 原因单据编号CHAR(15)
							tStockInOut.setOperator(ApplicationContext.OPERATOR_ID);// 操作人
							tStockInOut.setHappenTime(new Date());// 操作时间DATETIME
							tStockInOut.setTStore(new TStore(tConfig.getSellStoreID()));// 仓库
							tStockInOutService.saveService(tStockInOut);// 添加进数据库
							tStockInOutDetial.setTStockInOut(tStockInOut);// 入/出库单
							tStockInOutDetial.setTCommodity(tCommodity);// 商品
							tStockInOutDetailService.saveService(tStockInOutDetial);// 添加进数据库

							TBillDetail tBillDetail1 = new TBillDetail();
							tBillDetail1.setDetailID(UUID.GenUUID15());// 明细编号DECIMAL(20,3)PK
							tBillDetail1.setBillType(ApplicationContext.BILL_BILLTYPE3);// 单据类型
							tBillDetail1.setBillID(OrderNumTF.getText().getText().trim());// 单据编号CHAR(15)
							tBillDetail1.setCommodityID(tCommodity.getCommodityID());// 商品编号
							tBillDetail1.setNum(tCommodity.getNum());// 商品数量INTEGER
							tBillDetail1.setPrice(tCommodity.getDiscountPrice());// 现价DECIMAL(20,3)
//							tBillDetail1.setAvgPrice(tStock.getAvgPrice());//加权价
							if (tUser != null&& tUser.getTShopMemberLevel() != null) {
								tBillDetail1.setDiscount(tUser.getTShopMemberLevel().getDiscount());
								tBillDetail1.setDiscountID(tUser.getTShopMemberLevel().getLevelID());// 折扣编号CHAR(15)
							} else {
								tBillDetail1.setDiscount(0);
								tBillDetail1.setDiscountID("");
							}
							detailList.add(tBillDetail1);
							tBillDetailService.saveService(tBillDetail1);
						}
					}
					ApplicationContext.addMondyInOut(ApplicationContext.MONEYINOUT_TYPE_IN, 
							ApplicationContext.OPERATOR_ID, ApplicationContext.MONEYINOUT_SOURCE_TYPE3, OrderNumTF.getText().getText().trim());
					BuildSpringApplication.getInstance().getTOpLogServiceImpl().addOpLogService("添加销售订单信息");
//					 JOptionPane.showMessageDialog(null, "下单成功");
					 this.printOrder();// 打印
				} catch (Exception e1) {
					e1.printStackTrace();
					JOptionPane.showMessageDialog(null, "下单失败");
					return;
				}
				this.clear();
			}
		}
	}

	//查看会员信息
	private void lookMember() {
		try {
//			if (!flag) {
				String carID = carIDTF.getText().getText().trim();
				String tel = telTF.getText().getText().trim();
				if (carID.length() > 15) {
					JOptionPane.showMessageDialog(null, "会员编号不能超过15个字");
					return;
				}
				if (!carID.equals("")) {
					tUser = tUserService.getByCardNumService(carID);
					if (tUser == null)
						telTF.getText().setText("");
				} else if (carID.equals("") && !tel.equals("")) {
					tUser = tUserService.getByMobileService(tel);
					// if (tUser == null)
					// carIDTF.getText().setText("");
				} else {
					JOptionPane.showMessageDialog(null, "请输入会员编号或手机号");
					return;
				}
				if (tUser == null) {
					pointTemp.setVisible(false);
					trueNameTemp.setVisible(false);
					userLevelName.setVisible(false);
					moneyTemp.setVisible(false);
					JOptionPane.showMessageDialog(null, "不存在此会员信息，请重新输入");
					return;
				} else {
					pointTemp.setVisible(true);
					trueNameTemp.setVisible(true);
					userLevelName.setVisible(true);
					moneyTemp.setVisible(true);
					telTF.getText().setText(tUser.getMobile());
					carIDTF.getText().setText(tUser.getCardNum());
					pointTemp.getText().setText(tUser.getPoint() + "");
					trueNameTemp.getText().setText(tUser.getRealName());
					if (tUser.getTShopMemberLevel() != null
							&& tUser.getTShopMemberLevel().getName() != null)
						userLevelName.getText().setText(
								tUser.getTShopMemberLevel().getName());
					else
						userLevelName.getText().setText("无");
					moneyTemp.getText().setText(tUser.getMoney() + "");
					this.setOrderData();
					return;
//				}
			}
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		this.setOrderData();
	}
	// 打印
	private void printOrder() {
		if (memberConsumptionModel.getTCommodityList() == null|| memberConsumptionModel.getTCommodityList().size() <= 1) {
			JOptionPane.showMessageDialog(null, "请先购买商品");
			return;
		}
		if (dialog == null || dialog.gettOrder() == null) {
			JOptionPane.showMessageDialog(null, "请先结账");
			return;
		}
		List<TCommodity> commodityList = new ArrayList<TCommodity>();
		for (int i = 0; i < memberConsumptionModel.getTCommodityList().size(); i++) {
			TCommodity commodity = memberConsumptionModel.getTCommodityList().get(i);
			if (commodity.getBarcode() != null&& !commodity.getBarcode().equals("")) {
				commodityList.add(commodity);
			}
		}

		// 打印
		try {
			List<TConfig> configList = tConfigService.findService(null);
			if (configList == null || configList.size() == 0) {
				JOptionPane.showMessageDialog(null, "打印失败，请先到系统设置配置打印机");
				return;
			}
			TConfig config = configList.get(0);
			if (config.getSmallPrintName() == null) {
				JOptionPane.showMessageDialog(null, "打印失败，请先到系统设置配置打印机");
				return;
			} else if (config.getSmallPrintName().equals("")){
				return;//不打印时
			}
			if (tUser != null && tUser.getUserID() != null)
				new TicketPrint(null, dialog.gettOrder(), commodityList, config.getSmallPrintName(), true).start();
			else 
				new TicketPrint(null, dialog.gettOrder(), commodityList, config.getSmallPrintName(), false).start();
		} catch (Exception e1) {
			e1.printStackTrace();
		}
	}

	// 设置显示订单数据
	public void setOrderData() {
		double TotalManay = memberConsumptionModel.getTotalManay();
		totalMoneyTF.getText().setText(TotalManay + "");
		receivableMoneyTF.getText().setText(TotalManay + "");// 应收金额
		if (tUser != null && tUser.getTShopMemberLevel() != null) {
			double receivable = TotalManay
					- (TotalManay * tUser.getTShopMemberLevel().getDiscount());
			receivableMoneyTF.getText().setText(receivable + "");// 应收金额
			discountTF.getText().setText(
					tUser.getTShopMemberLevel().getDiscount() + "");// 折扣
			privilegeTF.getText().setText(TotalManay - receivable + "");// 优惠
			menberLevelTF.getText().setText(
					tUser.getTShopMemberLevel().getName());// 会员级别
			telTF.getText().setText(tUser.getPhone());// 手机号
		}
		this.setTableEdit(table.getRowCount() - 1, 1);
	}

	// 右边显示临时面板
	private JPanel showMenberInfoPanel() {
//		JPanel panel = uiFactory.createGridJPanel(1, 4);
		JPanel panel = uiFactory.createFlowJPanel(FlowLayout.LEFT);
		panel.setBackground(Util.PANEL_COLOR);
//		panel.setBorder(Util.PANEL_BORDER);
		pointTemp = new JLabelJTextFieldComponent(" 会员积分：", 20);
		pointTemp.getText().setEditable(false);
		pointTemp.getText().setBorder(new TopBottomLineBorder(new Color(171, 173, 179), true));
		pointTemp.getText().setOpaque(false);
		
		trueNameTemp = new JLabelJTextFieldComponent(" 会 员 名：", 20);
		trueNameTemp.getText().setEditable(false);
		trueNameTemp.getText().setBorder(new TopBottomLineBorder(new Color(171, 173, 179), true));
		trueNameTemp.getText().setOpaque(false);
		
		userLevelName = new JLabelJTextFieldComponent(" 会员级别：", 20);
		userLevelName.getText().setEditable(false);
		userLevelName.getText().setBorder(new TopBottomLineBorder(new Color(171, 173, 179), true));
		userLevelName.getText().setOpaque(false);
		
		moneyTemp = new JLabelJTextFieldComponent(" 卡 余 额：", 20);
		moneyTemp.getText().setEditable(false);
		moneyTemp.getText().setBorder(new TopBottomLineBorder(new Color(171, 173, 179), true));
		moneyTemp.getText().setOpaque(false);
		
//		pointTemp.setVisible(false);
//		trueNameTemp.setVisible(false);
//		userLevelName.setVisible(false);
//		moneyTemp.setVisible(false);

		panel.add(userLevelName);
		panel.add(trueNameTemp);
		panel.add(pointTemp);
		panel.add(moneyTemp);
		return panel;
	}

	@Override
	public void clear() {
//		pointTemp.setVisible(false);
//		trueNameTemp.setVisible(false);
//		userLevelName.setVisible(false);
//		moneyTemp.setVisible(false);

		carIDTF.getText().setText(""); // 会员卡号
		telTF.getText().setText(""); // 手机号
		OrderNumTF.getText().setText(UUID.GenUUID15());
		receivableMoneyTF.getText().setText("0.00");
		totalMoneyTF.getText().setText("0.00");
		discountTF.getText().setText("无");
		privilegeTF.getText().setText("0.00");
		menberLevelTF.getText().setText("无");
		tUser = null;
		memberConsumptionModel.getTCommodityList().clear();
		memberConsumptionModel = new MemberConsumptionModel(this);
		table.setModel(memberConsumptionModel);
		TableColumnModel colmodel = table.getColumnModel();
		for (int index = 0; index < table.getColumnCount(); index++) {
			TableColumn tc = colmodel.getColumn(index);
			JTextField editor = new JTextField();
			MemberConsumptionCellEditorTextField cellEditor = new MemberConsumptionCellEditorTextField(
					editor);
			cellEditor.setClickCountToStart(1);
			tc.setCellEditor(cellEditor);
		}

		CommodityJComboBoxTableComponent cbox = new CommodityJComboBoxTableComponent();
		cbox.setBorder(null);
		TableCellEditor edt = new DefaultCellEditor(cbox);
		table.getColumnModel().getColumn(2).setCellEditor(edt);

		this.setTableEdit(0, 1);
		try {
			 ClientDisplay.sendDisplay(ClientDisplay.DISPLAY_STATE_PRICE, "0");
		} catch (Exception e) {
			e.printStackTrace();
		}
		ApplicationContext.listenCard(carIDTF.getText(), ApplicationContext.CardType.CT_DLSended);
	}
}
